package cn.itcast.bos.interceptor;

import org.apache.struts2.ServletActionContext;

import cn.itcast.bos.domain.user.User;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;

// @Component("loginIntercepter")  注册 使用伪类名  注意 单例!
public class LoginInterceptor extends MethodFilterInterceptor {

	@Override
	protected String doIntercept(ActionInvocation invocation) throws Exception {
		// 登陆认证 session existUser 是否为空
		User existUser = (User) ServletActionContext.getRequest().getSession().getAttribute("existUser");
		if (existUser == null) {
			return "no_login";
		}
		return invocation.invoke();
	}

}
